home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: How do the functions in <time.h> work?
- Date: 21 Apr 1996 12:58:18 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4ldbda$t08@sparcserver.lrz-muenchen.de>
- References: <317653DA.5066@ix.netcom.com> <829950824snz@genesis.demon.co.uk> <317909EE.648E@ix.netcom.com>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- Jane Harper <jharper@ix.netcom.com> writes:
-
- >Lawrence Kirby wrote:
- >>
- >> We can't tell what you did unless you post some code. ctime() takes an
- >> argument which is a pointer to the time_t value you want to convert.
- >> Presumably you didn't pass it such a pointer.
-
- >About the immediate question of my code, you are correct. However, I'm
- >at least as interested in *how* the functions work. What's time_t a
- >typedef *for*?
-
- A type that is capable of storing a date and time.
-
- >DOes it have other uses? The ctime() prototype mentions
- >an argument "*timer" .. whazzat and what does *it* do? What type is it?
-
- If the prototype of ctime() is similar to
-
- char *ctime(const time_t *timer);
-
- as it should be, then
-
- "ctime" is a function taking a pointer to time_t, that will not be
- modified through that pointer by the function, and returning a pointer
- to char.
-
- >Perhaps my real problem lies in my inability to understand completely
- >the code within the <time.h> file ..
-
- The "code" inside a header file is limited to declarations and definitions
- in most cases. Standard C libraries are accompanied by a documentation,
- and the implementaion of that library should be documented in that
- documentation. Anyway, a short example might be helpful:
- ----------------------8<--------------8<---------------------------
- #include <time.h>
-
- main()
- {
- time_t now;
-
- time(&now); /* Get the current time and date */
- puts(ctime(&now)); /* Print a text representation thereof */
- return 0;
- }
- ----------------------8<--------------8<---------------------------
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
-